<%@page import="java.util.Date"%>
<%@page import="java.text.NumberFormat"%>
<%@page import="com.mongodb.DBCursor"%>
<%@page import="ipsite.controller.Utils"%>
<%@page import="com.mongodb.DBObject"%>
<% request.setCharacterEncoding("utf-8");%>
<%

DBObject domain = (DBObject) request.getAttribute("domain");
DBCursor subdomain = (DBCursor) request.getAttribute("subdomain");
DBCursor googleAnalytic = (DBCursor) request.getAttribute("googleAnalytic");
DBCursor googleAdsense = (DBCursor) request.getAttribute("googleAdsense");
DBCursor inlink = (DBCursor) request.getAttribute("inlink");
DBCursor ip = (DBCursor) request.getAttribute("ip");
DBCursor random = (DBCursor) request.getAttribute("random");
String search = (String) request.getAttribute("search");

String ips = (domain.get("ip") != null)?domain.get("ip").toString():domain.get("name").toString();

String re_title = domain.get("name").toString()+" hosted on "+ ips;

String google = (domain.get("googlePagerank")!=null)?domain.get("googlePagerank").toString():"0";
String rank = (domain.get("rank")!=null)?domain.get("rank").toString():"0";
String re_des = domain.get("name").toString()+" website has IP,"+ips+". Google pagerank is "+google+",alexa rank is "+rank;
String re_key = domain.get("name").toString()+","+ips+",website,site,ipsite,alexa,google pagerank,pagerank,whois,ip,related site,infomation site";

String title = domain.get("name")+" "+re_title;
String description = domain.get("name")+" "+re_des;
String keywords = re_key;

NumberFormat nf = NumberFormat.getInstance();

long date = new Date().getTime();
long dates = new Date().getTime();
if(domain.get("update") != null)
{
	dates = Long.parseLong(domain.get("update").toString());
}
long seconds = (date - dates)/1000;
long day = (int) (seconds / 86400);
long hour = (int) ((seconds - day*86400) / 3600);
long minute = (int) ((seconds - day*86400 - hour*3600) / 60);
if(hour<0)
{
	hour = 0;	
}
if(minute<0)
{
	minute = 0;	
}
if(day<0)
{
	day = 0;	
}
%>
<%@page contentType="text/html;charset=UTF-8" language="java"%>
<jsp:include page="./layout/header.jsp">
	<jsp:param name="title" value="<%=title %>"/>
	<jsp:param name="description" value="<%=description %>"/>
	<jsp:param name="keywords" value="<%=keywords %>"/>
</jsp:include>

<div id="content">
        	<div id="content_inner">
            	<div id="leftsidecontent">
                	<div class="domainname clearafter">

                    	<img src="http://chart.apis.google.com/chart?chs=60x60&cht=qr&chld=|0&chl=http://<%=domain.get("name") %>" alt="<%=domain.get("name") %>" title="<%=domain.get("name") %>" />
                        <h1><%=domain.get("name") %></h1>
                    </div>               
                    <hr />
                    <div class="update">
                    	Updated<b>
						<%
							if(day > 0)
							{
								out.print(day+" days, ");
							}
							if(hour > 0)
							{
								out.print(hour+" hours, ");
							}
							out.print(minute+" minutes");
						%>	
						</b> Ago
						<%
						if(day>=0 || domain.get("update") == null)
						{
						%>
									<strong class="size">( <a href="javascript:void(0)" rel="nofollow" id="update">Update</a> )</strong>
						<%
						}
						%>
						<br/>
						<%
						if(domain.get("gmail") != null && domain.get("gmail").toString().equals("1"))
						{
						%>
						<strong><%=domain.get("name") %></strong> use gmail service of google.com
						<%
						}
						%> 
						View <a href="http://5ty.org/d/<%=domain.get("name") %>" target="_blank"><%=domain.get("name") %></a> in 5ty.org
                    </div> 
                    <hr />
                    <div class="block clearafter">
                    	<div class="left adv-1">
                    		<%@ include file='/adv/left.jsp'%>
                    	</div>
                        <div class="left ranking">
                        	<h2>Ranking info of <%=domain.get("name") %></h2>
                            <ul class="clearafter">
                            	<li>
                                	<div class="left">Google pagerank</div>

                                    <div class="right"><%=(domain.get("googlePagerank")!=null)?domain.get("googlePagerank"):"-" %></div>
                                </li>
                                <li>
                                	<div class="left">Alexa rank : </div>
                                    <div class="right"><%=(domain.get("rank")!=null && !domain.get("rank").toString().equals("0"))?nf.format(domain.get("rank")):"-" %></div>
                                </li>
                            </ul>

                            <h2>Domain</h2>
                            <ul class="clearafter">
                            	<li>
                                	<div class="left">Domain name</div>
                                    <div class="right">
                                    	<strong><%=domain.get("name")%></strong>
                                        <br />

                                        <strong>Length: </strong> <%=Utils.checkLengthDomain(domain.get("name").toString()) %> characters 
                                    </div>
                                </li>
                                <li>
                                	<div class="left">Subdomain :</div>
                                    <div class="right"><strong><%=domain.get("name")%></strong> <%=Utils.returnSubDomain(domain.get("name").toString()) %></div>

                                </li>
                                <li>
                                	<div class="left">Favicon :</div>
                                    <div class="right"><img src="https://s2.googleusercontent.com/s2/favicons?domain_url=http://<%=domain.get("name")%>" /></div>
                                </li>
                            </ul>
                        </div>
                    </div>
                    <div class="adv-2">
                    	<%@ include file='/adv/adv468.jsp'%>
                    </div>
					<%
					if(domain.get("ip")!=null)
					{
					%>
                    <div class="block">
                    	<h2>Whois ip <a href='/i/<%=domain.get("ip") %>'><%=domain.get("ip") %></a></h2>

                        <div class="whois">
                        	<%=(domain.get("wip")!=null)?Utils.returnWhois(domain.get("wip").toString()):"" %>

                        </div>
                    </div>
                    <%
					}
					%>
					<div class="adv-2">
                    	<%@ include file='/adv/menu.jsp'%>
                    </div>
                    <div class="block">
                    	<h2>Whois <%=domain.get("name") %> ( <a href="/w/<%=domain.get("name")%>">More detail ...</a> )</h2>
                        <div class="whois">
                        	<%=(domain.get("whois")!=null)?Utils.returnWhois(domain.get("whois").toString()):"" %>

                        </div>
                    </div>
                    <div class="adv-2">
                    	<%@ include file='/adv/menu.jsp'%>
                    </div>
                    <div class="block">
                    	<h2>DNS Record <%=domain.get("name") %></h2>
                        <div class="whois">
                        	<%=(domain.get("dig")!=null)?domain.get("dig"):"" %>

                        </div>
                    </div>
                    <div class="adv-2">
                    	<%@ include file='/adv/menu.jsp'%>
                    </div>
                    <div class="block">
                    	<h2>NSLOOKUP <%=domain.get("name") %></h2>
                        <div class="whois">
                        	<%=(domain.get("ns")!=null)?domain.get("ns"):"" %>

                        </div>
                    </div>         
                    <div class="block clearafter">                    	
                        <h2>Site parameters of <%=domain.get("name") %></h2>
                        <ul class="clearafter">
                            <li>
                                <div class="left">Estimate Visitor per Day</div>
                                <div class="right"><%=(domain.get("visit")!=null && !domain.get("visit").equals("-"))?nf.format(Math.ceil(((350*Float.parseFloat(domain.get("visit").toString()))*80)/0.03))+" - "+nf.format(Math.ceil(((350*Float.parseFloat(domain.get("visit").toString()))*120)/0.03)):"-" %></div>
                            </li>
                            <li>

                                <div class="left">Speed site : </div>
                                <div class="right"><%=(domain.get("speed")!=null)?Float.valueOf(domain.get("speed").toString())+" Seconds":"-" %></div>
                            </li>
                            <li>
                                <div class="left">Domain Age : </div>
                                <div class="right"><%=(domain.get("age")!=null)?domain.get("age"):"-" %></div>
                            </li>

                            <li>
                                <div class="left">Charset : </div>
                                <div class="right"><%=(domain.get("charset")!=null)?domain.get("charset"):"-" %></div>
                            </li>
                            <li>
                                <div class="left">WOT : </div>
                                <div class="right"><%=(domain.get("wot")!=null)?domain.get("wot"):"-" %></div>

                            </li>
                            <li>
                                <div class="left">Page speed : </div>
                                <div class="right" id='page_speed'><a href="javascript:void(0)" onclick="runPagespeed()">Check now</a></div>
                            </li>
                        </ul>
                    </div>
					<%
					if(subdomain != null && subdomain.size() > 0)
					{
					%>
                    <div class="block">
                    	<h2>Other domain of <%=Utils.returnSubDomainTo(domain.get("name").toString())  %> ( <a href="/sd/<%=Utils.returnSubDomainTo(domain.get("name").toString())%>">View all</a> )</h2>
                        <ul class="clearafter">
                        	<li>                        	
                                <%
									while(subdomain.hasNext())
									{
										String name = subdomain.next().get("name").toString();
								%>
										<a href="/d/<%=name %>"><%=name %></a> | 
								<%
									}
								%>                         	
                            </li>

                        </ul>                        
                    </div>
                    <%
					}
					%>
                    
                    <div class="block">
                    	<h2>Site contact info of <%=domain.get("name") %></h2>
                        <ul class="clearafter">
                            <li>
                                <div class="left">

                                	Site's same Google Analytic :
                                    <br />
									<%=(domain.get("googleAnalytics")!=null)?domain.get("googleAnalytics"):"-" %>
                                </div>
                                <div class="right">
                                	<%
									if(googleAnalytic != null && googleAnalytic.size()>0)
									{
										while(googleAnalytic.hasNext())
										{
											String name = googleAnalytic.next().get("name").toString();
											out.print("<a href='/d/"+name+"'>"+name+"</a> | ");
										}
									}
									%> 
                                </div>

                            </li>
                            <li>
                            	<div class="left">Site's same Google Adsense :<br/><%=(domain.get("googleAdsense")!=null)?domain.get("googleAdsense"):"-" %></div>
                                <div class="right">
                                	<%
									if(googleAdsense != null && googleAdsense.size()>0)
									{
										while(googleAdsense.hasNext())
										{
											String name = googleAdsense.next().get("name").toString();
											out.print("<a href='/d/"+name+"'>"+name+"</a> | ");
										}
									}
									%>
                                </div>                            	
                            </li>
                        </ul>
                    </div>
                    <div class="block">
                    	<h2>Site Technical Info of <%=domain.get("name") %></h2>

                        <ul class="clearafter">
                            <li>
                                <div class="left">Programming Language : </div>
                                <div class="right"><%=(domain.get("language")!=null)?domain.get("language"):"-" %></div>                                	
                            </li>
                            <li>
                            	<div class="left">Web server : </div>
                                <div class="right"><%=(domain.get("server")!=null)?domain.get("server"):"-" %></div>                            	
                            </li>

                            <li>
                            	<div class="left">Javascript library : </div>
                                <div class="right"><%=(domain.get("js")!=null)?Utils.returnString(domain.get("js").toString(),""):"-" %></div>                            	
                            </li>
                            <li>
                            	<div class="left">
                                	IP Address :
                                    <br />
                                    <%=(domain.get("ip")!=null)?"<a href='/i/"+domain.get("ip")+"'>"+domain.get("ip")+"</a>":"-" %>

                                </div>
                                <div class="right">
                                	<%
									if(ip != null && ip.size()>0)
									{
										while(ip.hasNext())
										{
											String name = ip.next().get("name").toString();
											out.print("<a href='/d/"+name+"'>"+name+"</a> | ");
										}
									}
									%>
                                </div>                            	
                            </li>
                        </ul>
                    </div>
                               
                    <div class="block">
                    	<h2>Site Seo of <%=domain.get("name") %></h2>
                        <ul class="clearafter">
                            <li>
                                <div class="left">Tag : </div>
                                <div class="right">

                                	<table cellspacing="0" cellpadding="0" class="table-information seo-info">
										<thead>
                                            <tr>
                                                <th>H1</th>
                                                <th>H2</th>
                                                <th>H3</th>
                                                <th>H4</th>

                                                <th>H5</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <tr>
                                                <th><%=(domain.get("h1")!=null)?domain.get("h1"):"0" %></th>
												<th><%=(domain.get("h2")!=null)?domain.get("h2"):"0" %></th>
												<th><%=(domain.get("h3")!=null)?domain.get("h3"):"0" %></th>
												<th><%=(domain.get("h4")!=null)?domain.get("h4"):"0" %></th>
												<th><%=(domain.get("h5")!=null)?domain.get("h5"):"0" %></th>
                                            </tr>
										</tbody>
									</table>
                                </div>                                	
                            </li>

                            <li>
                            	<div class="left">Image : </div>
                                <div class="right">
                                	We found <b><%=(domain.get("img")!=null)?domain.get("img"):"-" %></b> images on this website.
									<%=(domain.get("altImg")!=null)?"<br/>There are <b>"+domain.get("altImg")+" </b>images alt attribute":"-" %>
                                </div>                            	
                            </li>

                            <li>
                            	<div class="left">Frame : </div>
                                <div class="right"><b><%=(domain.get("frame")!=null && !domain.get("frame").equals(0))?domain.get("frame"):"No" %></b></div>                            	
                            </li>
                            <li>
                            	<div class="left">Flash : </div>
                                <div class="right"><b><%=(domain.get("flash")!=null && !domain.get("flash").equals(0))?domain.get("flash"):"No" %></b></div>                            	
                            </li>

                            <li>
                            	<div class="left">Size : </div>
                                <div class="right"><b><%=(domain.get("size")!=null)?nf.format(domain.get("size"))+" characters":"-" %></b></div>                            	
                            </li>
                            <li>
                            	<div class="left">Meta Description : </div>
                                <div class="right"><b><%=(domain.get("metaDesc")!=null && domain.get("metaDesc").equals(1))?"Yes":"No" %></b></div>                            	
                            </li>

                            <li>
                            	<div class="left">Meta Keyword : </div>
                                <div class="right"><b><%=(domain.get("metaKey")!=null && domain.get("metaKey").equals(1))?"Yes":"No" %></b></div>                            	
                            </li>
                        </ul>
                    </div>                    
                    <div class="block">
                    	<h2>Cross link of <%=domain.get("name") %></h2>

                        <ul class="clearafter">
                            <li>
                                <div class="left">Out link : </div>
                                <div class="right">
                                	<%
										if(domain.get("link")!=null)
										{
											out.print(Utils.returnString(domain.get("link").toString(),"d"));
										}
									%> 
                                </div>                                	
                            </li>

                            <li>
                            	<div class="left">Back link : </div>
                                <div class="right">
                                	<%
									if(inlink != null && inlink.size()>0)
									{
										while(inlink.hasNext())
										{
											String name = inlink.next().get("name").toString();
											out.print("<a href='/d/"+name+"' >"+name+"</a> | ");
										}
									}
									%> 
                                </div>                            	
                            </li>

                        </ul>
                    </div>       
                    <%
					if(domain.get("rank") != null && Integer.valueOf(domain.get("rank").toString()) < 110000)
					{
					%>             
                    <div class="block">
                    	<h2>Domain Traffic Graph of <%=domain.get("name") %></h2>
                        <ul class="clearafter traffic-graph">
                            <li>
                                <div>
                                    <h3 class="daily">Daily Rank</h3>

                                    <img src="http://traffic.alexa.com/graph?c=1&amp;u=<%=domain.get("name") %>&amp;r=6m&amp;y=t&amp;z=3&amp;h=200&amp;w=280&amp;b=FFFFFF">
                                </div>
                                <div>
                                    <h3 class="daily">Daily Page Views</h3>
                                    <img src="http://traffic.alexa.com/graph?c=1&amp;u=<%=domain.get("name") %>&amp;r=6m&amp;y=r&amp;z=3&amp;h=200&amp;w=280&amp;b=FFFFFF">
                                </div>
                            </li>
                        </ul>

                    </div>
                    <%
					}
					%>
					<%
					if(domain.get("rank") != null && Integer.valueOf(domain.get("rank").toString()) < 1000000)
					{
					%>
                    <div class="block">
                    	<h2>Unique Visitors of <%=domain.get("name") %></h2>
                        <ul class="clearafter traffic-graph unique">
                            <li>
                                <div>
									<img src="http://grapher.compete.com/<%=domain.get("name") %>_uv_310.png" class="img_test">
                                </div>

                                <div>
                                    <%
									while(random.hasNext())
									{
										String name = random.next().get("name").toString();
										out.print("<a href='/d/"+name+"'>"+name+"</a> | ");
									}
									%>
                                </div>
                            </li>
                        </ul>
                    </div>
                    <%
					}
					%>
                </div>

                <div id="rightsidecontent">
                	<div class="adv-1">
                		<%@ include file='/adv/left.jsp'%>
                	</div>
                    <div class="box">
                    	<%@ include file='/element/spot_check.jsp'%>

                    </div>
                    <div class="box">
                    	<h3>Recent site update</h3>
                        <div class="content-box">
                        	<%@ include file='/element/site_update.jsp'%>
                        </div>
                    </div>
                    <div class="box">
                        <%@ include file='/element/site_random.jsp'%>
                    </div>
                    <div class="box">

                    	<h3>Related Site</h3>
                        <div class="content-box myads">
                        	<a href="http://thedomaintips.appspot.com/" rel="nofollow" target="_blank">
                        		<img src="http://5ty.org/images/domaintips.png" alt="http://thedomaintips.appspot.com/" title="http://thedomaintips.appspot.com/" />
                            </a>
                            <hr />
                            <a href="http://dev.gardenquestions.com/" rel="nofollow" target="_blank">
                        		<img src="http://5ty.org/images/faq.png" alt="http://dev.gardenquestions.com/" title="http://dev.gardenquestions.com/" />

                            </a>
                            <hr />
                            <a href="http://prapi.net/" rel="nofollow" target="_blank">
                        		<img src="http://5ty.org/images/prapi.png" alt="http://prapi.net/" title="http://prapi.net/" />
                            </a>
                            <hr />
                            <a href="http://www.yooarticles.com/" rel="nofollow" target="_blank">
                        		<img src="http://5ty.org/images/yoo.png" alt="http://www.yooarticles.com/" title="http://www.yooarticles.com/" />
                            </a>

                        </div>
                    </div>
                </div>
                <div class="clearbreak"></div>
            </div>
        </div>
<div id='opacity'></div>
<img src="/images/ajax-loader.gif" id='image_loadder'/>	
<script type="text/javascript">
	var domain = '<%=domain.get("name")%>';
	
</script>	
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="/js/detail.js"></script>
	
<%@ include file='/layout/footer.jsp'%>		